﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace Application2
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class BlankPage : Page
    {
        public BlankPage()
        {
            this.InitializeComponent();
            Elements2.SelectionChanged += Elements2_SelectionChanged;
        }

        void Elements2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Changed();
        }

        private async void Changed()
        {
            var dialog = new MessageDialog("Selection changed");
            await dialog.ShowAsync();
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void ToggleSwitch_Toggled_1(object sender, RoutedEventArgs e)
        {
            if (ToggleList.IsOn)
            {
                Elements1.Visibility = Visibility.Collapsed;
                Elements2.Visibility = Visibility.Visible;
            }
            else
            {
                Elements2.Visibility = Visibility.Collapsed;
                Elements1.Visibility = Visibility.Visible;
            }
        }

        private void Button_Tapped_1(object sender, TappedRoutedEventArgs e)
        {
            if (Elements2.SelectedItem == Hydrogen)
            {
                if (Reaction.Text == "")
                {
                    Reaction.Text = Hydrogen.Name;
                }
                else
                {
                    Reaction.Text = Reaction.Text + " + " + Hydrogen.Name;
                }
            }

                if (Elements2.SelectedItem == Helium)
                {
                    if (Reaction.Text == "")
                    {
                        Reaction.Text = Helium.Name;
                    }
                    else
                    {
                        Reaction.Text = Reaction.Text + " + " + Helium.Name;
                    }
                }

                    if (Elements2.SelectedItem == Lithium)
                    {
                        if (Reaction.Text == "")
                        {
                            Reaction.Text = Lithium.Name;
                        }
                        else
                        {
                            Reaction.Text = Reaction.Text + " + " + Lithium.Name;
                        }
                    }
                    }
                }
            }
       